#ifndef QVALUEXML_H
#define QVALUEXML_H

#include "sharedlibglobal.h"

#include <QList>
#include <QMap>
#include <QWidget>

#include <QVariant>
#include <QStringList>


class QXmlStreamReader;
class QXmlStreamWriter;

namespace SHAREDLIB
{

    class SHAREDLIB_EXPORT XMLValue
    {
    public:
        virtual     void read(QXmlStreamReader *r)=0;
                    void write(QXmlStreamWriter *w);

        QVariant    value();
        void        setValue(QVariant value);

        virtual QString     valueText();

        void        setType(const QString &type);

        virtual QWidget*    valueEditor()=0;
    protected:
        virtual QVariant    defaultValue();
        virtual void        writeValue(QXmlStreamWriter *w);
    protected:
        QString     readSubValue(QXmlStreamReader *r);
    protected:
        QVariant    m_value;
        QString     m_type;
    };

    class SHAREDLIB_EXPORT XMLStringValue: public XMLValue
    {
    public:
        virtual     void read(QXmlStreamReader *r);
        virtual     void writeValue(QXmlStreamWriter *w);

        QWidget*     valueEditor();
    protected:
        virtual QVariant    defaultValue();
    };

    class SHAREDLIB_EXPORT XMLIntValue: public XMLValue
    {
    public:
        virtual     void read(QXmlStreamReader *r);
        virtual     void writeValue(QXmlStreamWriter *w);

        QWidget*     valueEditor();

        virtual QString     valueText();
    protected:
        virtual QVariant    defaultValue();
    };

    class SHAREDLIB_EXPORT XMLFloatValue: public XMLValue
    {
    public:
        virtual     void read(QXmlStreamReader *r);
        virtual     void writeValue(QXmlStreamWriter *w);

        QWidget*     valueEditor();

        virtual QString     valueText();
    protected:
        virtual QVariant    defaultValue();
    };

    class SHAREDLIB_EXPORT XMLBoolValue: public XMLValue
    {
    public:
        virtual     void read(QXmlStreamReader *r);
        virtual     void writeValue(QXmlStreamWriter *w);
        QWidget*     valueEditor();

        virtual QString     valueText();
    protected:
        virtual QVariant    defaultValue();
    };

    class SHAREDLIB_EXPORT XMLTimeValue: public XMLValue
    {
    public:
        virtual     void read(QXmlStreamReader *r);
        virtual     void writeValue(QXmlStreamWriter *w);

        QString          valueText();
        QWidget*     valueEditor();

    protected:
        virtual QVariant    defaultValue();
    };

    class SHAREDLIB_EXPORT XMLDateValue: public XMLValue
    {
    public:
        virtual     void read(QXmlStreamReader *r);
        virtual     void writeValue(QXmlStreamWriter *w);

        QString          valueText();
        QWidget*     valueEditor();
    protected:
        virtual QVariant    defaultValue();
    };

    class SHAREDLIB_EXPORT XMLDateTimeValue: public XMLValue
    {
    public:
        virtual     void read(QXmlStreamReader *r);
        virtual     void writeValue(QXmlStreamWriter *w);

        QString          valueText();
        QWidget*     valueEditor();
    protected:
        virtual QVariant    defaultValue();
    };

    class SHAREDLIB_EXPORT XMLValueFactory
    {
    public:
        static XMLValue *create(const QString &type);
        static QStringList supports();
    };

}

#endif // QVALUEXML_H
